Skip to content

fix(claude): avoid repeating role in member subagent descriptions - #2554

Open
aloneangel45 wants to merge 1 commit into
github:devfrom
aloneangel45:aloneangel45/2528-claude-member-dedup-description
Open

aloneangel45 wants to merge 1 commit into
github:devfrom
aloneangel45:aloneangel45/2528-claude-member-dedup-description

Conversation

@aloneangel45

Copy link
Copy Markdown

Summary

  • Avoid repeating the role in renderClaudeMember frontmatter description when the member's name already matches role (trimmed, case-insensitive, ignoring trailing punctuation/whitespace on role).
  • Exclude routed workType entries matching role from Owns: so descriptions don't duplicate the role phrase, omitting Owns: altogether when no distinct work types remain.
  • Add unit tests in test/claude-members.test.ts covering role=name deduplication, case/trailing-dot normalization, mixed work types, and explicit Purpose precedence, plus a changeset for @bradygaster/squad-sdk.

Verification

  • npm run build (packages @bradygaster/squad-sdk and @bradygaster/squad-cli)
  • npm run lint (tsc --noEmit across both packages - 0 errors)
  • npm run lint:eslint (0 errors)
  • npx vitest run test/claude-members.test.ts (21/21 passed)
  • node scripts/check-shebang-eol.mjs, node scripts/check-changeset-drift.mjs --mode=warn, node scripts/release/workspace-lockfile.mjs check

Closes #2528

Copilot AI adaptive review requested due to automatic review settings November 26, 2026 01:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The work-type filter uses a regex with quadratic backtracking on unbounded routing values, allowing a crafted row to block Claude member generation before the description-length limit applies.

1 open issue
What changed in this PR

This PR addresses #2528 by removing repeated role text from generated Claude member subagent descriptions.

Changes:

  • Deduplicates matching names, roles, and routed work types while preserving explicit purpose text.
  • Adds tests for normalization, mixed work types, and purpose precedence.
  • Adds a patch changeset for @bradygaster/squad-sdk.
File Description
test/​claude-members.test.ts Adds description deduplication regression tests.
packages/​squad-sdk/​src/​client/​adapters/​claude-members.ts Normalizes role comparisons and omits redundant description text.
.changeset/​fix-claude-member-role-dedup.md Records the SDK patch release change.

Review effort: Balanced (adaptive)

Comment on lines +148 to +153
const cleanRole = role?.replace(/[.\s]+$/, '').trim();
const roleKey = cleanRole ? cleanRole.toLowerCase() : undefined;
const routed = routing
.filter((r) => r.routeTo === id)
.map((r) => r.workType)
.filter((workType) => !roleKey || workType.replace(/[.\s]+$/, '').trim().toLowerCase() !== roleKey);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9e6f1ec: extracted a linear backward-scan helper stripTrailingDotsAndSpace and shared it across both role normalization and the routing workType filter to avoid regex backtracking. Re-verified locally with npm run build, npm run lint, npm run lint:eslint, and npx vitest run test/claude-members.test.ts (21/21 passed).

@aloneangel45
aloneangel45 force-pushed the aloneangel45/2528-claude-member-dedup-description branch from 3a02bf0 to 9e6f1ec Compare November 26, 2026 01:38
Closes github#2528

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude member subagent description repeats itself when name equals role ("QA Engineer, QA Engineer.")

2 participants